import { NextResponse } from 'next/server';
import productInformationModule from '@/modules/product';
import templates from '@/template/products/config'

export async function GET(request, { params }) {
  const codeMap = { 0: '获取成功',1: 'ID 不存在' , 2: '内容为空' };
  const { id } = await params;
  if (!id) { return NextResponse.json({ code: 1, codeMap, message: 'Product ID does not exist' })}
  const productInformation = await productInformationModule.getAllInformationById(Number(id));
  if (!productInformation) { return NextResponse.json({ code: 1, codeMap, message: 'No productInformations found' }); }
  return NextResponse.json({ code: 0, codeMap, message: 'Success', data: { ...productInformation, product: {...productInformation.product, templates} } });
}